/*
 * ConsoleWorkItem.h
 *
 *  Created on: Mar 5, 2012
 *      Author: mikaelgra
 */

#include "gpio/Define.h"

#ifndef CONSOLEWORKITEM_H_
#define CONSOLEWORKITEM_H_

/**
 * Defines the maximum length of the result the user can
 * type as response to a WorkItem.
 */
#define MAX_RESULT_LENGTH 20

/**
 * Structure defining a WorkItem
 */
struct stConsoleWorkItem_t
{
	unsigned char type;
	bool_t requireInput;
	char *displayText;
	char *result;
};

/**
 * This creates a new ConsoleWorkItem and places it on
 * the heap.
 *
 * @param displayText
 * 		This is the text displayed in the console when
 * 		this ConsoleWorkItem is processed.
 */
struct stConsoleWorkItem_t* ConsoleWorkItem_New(char *displayText, bool_t requireInput, unsigned char type);

/**
 * This frees up any member used by the ConsoleWorkItem.
 *
 * @param item
 * 		This is the ConsoleWorkItem to be freed.
 * @param requireInput
 * 		This a boolean indicating whether or not this
 * 		ConsoleWorkItem requires input.
 * @param type
 * 		This is a identifier which identifies the type
 * 		of input this ConsoleWorkItem requires.
 */
void ConsoleWorkItem_Finalize(struct stConsoleWorkItem_t* item);

/**
 * Sets the result parameter of the ConsoleWorkItem
 * using the stack.
 *
 * @param item
 * 		This is the ConsoleWorkItem that the result
 * 		should be set on.
 * @param result
 * 		This is the string that will be copied onto
 * 		the heap and copied into the result.
 */
void ConsoleWorkItem_SetResult(struct stConsoleWorkItem_t* item, char* result);

#endif /* CONSOLEWORKITEM_H_ */
